//
//  LYMeAvatarTableViewCell.swift
//  WeChat
//
//  Created by mac on 2018/8/2.
//  Copyright © 2018年 RRC. All rights reserved.
//

import UIKit

class LYMeAvatarTableViewCell: UITableViewCell {

    var avatarImageView:UIImageView!
    var nicknameLabel:UILabel!
    var wechatIDLabel:UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.accessoryType = .disclosureIndicator
        
        avatarImageView = UIImageView()
        avatarImageView.image = UIImage(named: "Kenny.jpg")
        self.addSubview(avatarImageView)
        avatarImageView.snp.makeConstraints { (make) in
            make.leading.equalTo(6)
            make.centerY.equalTo(self)
            make.width.height.equalTo(65)
        }
        
        nicknameLabel = UILabel()
        nicknameLabel.text = "黑凤梨"
        nicknameLabel.textColor = UIColor.black
        nicknameLabel.font = UIFont.systemFont(ofSize: 17)
        self.addSubview(nicknameLabel)
        nicknameLabel.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.leading.equalTo(avatarImageView.snp.trailing).offset(12)
            make.height.equalTo(21)
            make.trailing.equalTo(65)
        }
        
        wechatIDLabel = UILabel()
        wechatIDLabel.text = "微信号：heifengli"
        wechatIDLabel.textColor = UIColor.black
        wechatIDLabel.font = UIFont.systemFont(ofSize: 14)
        self.addSubview(wechatIDLabel)
        wechatIDLabel.snp.makeConstraints { (make) in
            make.leading.equalTo(avatarImageView.snp.trailing).offset(12)
            make.top.equalTo(nicknameLabel.snp.bottom).offset(8)
            make.height.equalTo(21)
            make.trailing.equalTo(100)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        avatarImageView.layer.masksToBounds = true
        avatarImageView.layer.cornerRadius = avatarImageView.width / 2 / 180*30
        avatarImageView.layer.borderWidth = 0.5
        avatarImageView.layer.borderColor = UIColor.lightGray.cgColor
    }
}
